<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="../jquery-1.7.2.js"></script>
    <script type="text/javascript">
        $(function(){
            var deleteFun = function(){
                var $strObj = $(this).parent().parent();
                var name = $strOnj.find("td:first").text();
                if(confirm("你是否删除["+name+"]?")){
                    $strObj.remove();}
                return false;
            };

        $("#addEmpButton").click(function(){
            var name = $("#emname").val();
            var email = $("#email").val();
            var salary = $("#salary").val();
            var $strObj = $("<tr>"+
                                "<td>"+name+"</td>"+
                                "<td>"+email+"</td>"+
                                "<td>"+salary+"</td>"+
                                 "<td><a href=\"deleteEmp?id=002\">Delete</a></td>"+
                "</tr>");
            $strObj.appendTo($("#employeeTable"));
            $strObj.find("a").click(deleteFun);
            })
            $("a").click(deleteFun);
        })

        $("a[name = 'Test']").click(function(){
            alert("Hello");
            return false;
        })
    </script>
</head>
<body>
<table id="employeeTable">
    <tr>
        <th>Name</th>
        <th>Email</th>
        <th>Salary</th>
        <th>&nbsp;</th>
    </tr>
    <tr>
        <td>Tom</td>
        <td>tom@tom.com</td>
        <td>5000</td>
        <td><a href="deleteEmp?id=001">Delete</a></td>
    </tr>
    <tr>
        <td>Jerry</td>
        <td>jerry@sohu.com</td>
        <td>8000</td>
        <td><a href="deleteEmp?id=002">Delete</a></td>
    </tr>
    <tr>
        <td>Bob</td>
        <td>bob@tom.com</td>
        <td>10000</td>
        <td><a href="deleteEmp?id=003">Delete</a></td>
    </tr>
</table>
<div id="formDiv">
    <h4>添加新员工</h4>
    <table>
        <tr>
            <td class="word">name: </td>
            <td class="inp">
                <input type="text" name="empName" id="empName" />
            </td>
        </tr>
        <tr>
            <td class="word">email: </td>
            <td class="inp">
                <input type="text" name="email" id="email" />
            </td>
        </tr>
        <tr>
            <td class="word">salary: </td>
            <td class="inp">
                <input type="text" name="salary" id="salary" />
            </td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <button id="addEmpButton" value="abc">
                    Submit
                </button>
            </td>
        </tr>
    </table>
</div>
<br/><br/>
<a href = "1.1_按件绑定.html" name = "Test">Test</a>
</body>
</html>